home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: RND
- References: <709.6578T1027T1962@login.eunet.no>
- X-Newsreader: TIN [version 1.2 PL2]
- Path: imada.ou.dk!breese
- From: breese@imada.ou.dk (Bjorn Reese)
- Message-ID: <1996Jan6.190221.7989@imada.ou.dk>
- Sender: news@imada.ou.dk
- Nntp-Posting-Host: wagner.imada.ou.dk
- Organization: Dept. of Math. & Computer Science, Odense University, Denmark
- Date: Sat, 6 Jan 1996 19:02:21 GMT
- Newsgroups: comp.sys.amiga.programmer
-
- Patrick Hanevold (patrick.hanevold@login.eunet.no) wrote:
-
- > RND MACRO
- > move.w (a0),\1
- > move.w 2(a0,\1.l*2),\1
- > move.w \1,(a0)
- > ENDM
-
- This is very likely to result in a cycle, hence decreasing the
- random sequence drastically.
-
- A way to get around this problem is to use an additive pseudo-
- random generator (warning: off the top of my head)
-
- Init:
- - Keep an array of N elements. N is 2^n. Each element is seeded
- by another - more CPU intensive - random generator.
- - Use two indexes, i1 = 0 and i2 = N - 3
-
- Random:
- - Update the indexes (i = (i - 1) AND (N-1))
- - rnd = array[i1] + array[i2]
- - array[i2] = rnd
- - Return rnd
-
- --
- Bjorn Reese Email: breese@imada.ou.dk
- Odense University, Denmark URL: http://www.imada.ou.dk/~breese
-
- "It's getting late in the game to show any pride or shame" - Marillion
-